<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>问题详情页</title>
</head>
<body>
  <h1>{{ question.question_text }}</h1>

  {#错误提示#}
  {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}

  <form action="{% url 'polls:vote' question.id %}" method="post" >
    {% csrf_token %}
    {% for choice in question.choice_set.all %}
      <input type="radio" name="choice"
             id="choice{{ forloop.counter }}" value="{{ choice.id }}">
      <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label>
    {% endfor %}
    <input type="submit" value="投票">
  </form>




  {#写法3#}
{#  <ul>#}
{#    {% for choice in question.choice_set.all %}#}
{#      <li>{{ choice.choice_text }}</li>#}
{#    {% endfor %}#}
{#  </ul>#}


{#  建议所有业务逻辑放后端，前端尽可能简单，变量直接渲染使用#}
{#  {% for c in choices %}#}
{#    <p>{{ c.choice_text }}</p>#}
{#  {% endfor %}#}
</body>
</html>